Skip to main content

Affective computing service protocol

Relying on bio-data analysis services, we provide services such as attention, relaxation, and pressure value calculation.

caution

The service requires our authorization before it can be used.

ServiceOperationRemarks
affectivestartstarts, initializes the affective computing service
subscribesubscribe to real-time affective computing data
unsubscribeunsubscribe to real-time affective computing data
reportGet a report on the current affective computing cloud service
finishfinish a cloud service

Affective Start

Starts the Affective Cloud Computing service.

Request

{
"services": "affective",
"op": "start",
"kwargs": {
"cloud_services": [
cloud_service1, # attention, relaxation, pressure, etc.
cloud_serviceN
]
}
}

Request Example

{
"services": "affective",
"op": "start",
"kwargs": {
"cloud_services": [
"attention",
"sleep"
]
}
}

Response

{
"code": 0,
"request": {
"services": "affective",
"op": "start"
},
"data": {
"cloud_service": [
cloud_service1, # The type of cloud service that has been started
cloud_serviceN
]
}
}

Affective Subscribe

Subscribe to the Affective Cloud Service real-time data. The analysis return value is an optional service. If you need to receive the value returned by the analysis in real time, enable this subscription and configure the parameters to be returned. See the following table for the specific parameters.

caution

Subscribe has two types of Responses:

  • Subscribe Success Response
  • Subscribe Data Response

Subscribe Request structure

{
"services": "affective",
"op": "subscribe",
"args": [affective_service_type1, affective_service_type2] # Affective computing service type
}

Request Example

{
"services": "effective",
"op": "subscribe",
"args": ["attention", "sleep"]
}

Subscribe structure

Subscription Status Response The status return value of a successful subscription. Will return all computing services that are subscribed to.

{
"code": 0,
"request": {
"services": "affective",
"op": "subscribe"
},
"data": {
"sub_" + cloud_service1 + "_fields": [ # cloud_service1: cloud service type, attention, relaxation, pressure, etc.
data_type1, data_typeN, # subscribed data, see affective cloud service parameter column for details
]
"sub_" + cloud_serviceN + "_fields": [
data_type1, data_typeN,
]
}
}

Subscription Data Response

The data returned depends on the data set at the time of Affective Subscribe.

Affective cloud computing returns data service and parameter items in real time

cloud_servicedata_typetypevalue rangedescription
attentionattentionfloat[0, 100]Attention value, higher value means higher attention
relaxationrelaxationfloat[0, 100]The relaxation value, with higher values indicating higher relaxation
pressurepressurefloat[0, 100]The value of pressure level, with higher values indicating higher levels of pressure
arousalarousalfloat[0, 100]The value of activation, with higher values indicating higher affective activation
sleepsleep_degreefloat[0, 100]The degree of sleep, with smaller values indicating deeper sleep.
sleep_stateint{0, 1}The sleep state, 0 means not asleep, 1 means asleep
{
"code": 0,
"request": {
"services": "affective",
"op": "subscribe"
},
"data": {
cloud_service1: { # Cloud service data type, attention, relaxation, pressure, etc.
data_type1: data1, # Data type, packet, see the Affective Cloud Service data table for details
data_typeN: dataN,
},
cloud_serviceN: {
data_type1: data1,
data_typeN: dataN,
}
}
}
}

Affective Unsubscribe

Unsubscribe from the Affective Cloud Service real-time data.

Unsubscribe Request structure

{
"services": "affective",
"op": "unsubscribe",
"args": [affective_service_type]
}

Request Example

{
"services": "affective",
"op": "unsubscribe",
"args": ["attention"]
}

Unsubscribe Response structure

{
"code": 0,
"request": {
"services": "affective",
"op": "unsubscribe"
},
"data": {
"sub_" + cloud_service1 + "_fields": [ # cloud_service1: cloud service data type, attention, relaxation, pressure, etc.
data_type1, data_typeN, # subscribed data, see the affective cloud service data table parameter column for details
]
"sub_" + cloud_serviceN + "_fields": [
data_type1, data_typeN,
]
}
}

Affective Report

After the number of packets returned by the subscription service has reached the required number, you can request a service data report. The report returns an analysis of all values from the start of the service to the execution of the operation. The specific report results that can be returned are shown in the following table.

Report call interval

caution
  • The report can be requested only after the number of packets returned by the subscription service has reached the required number, otherwise the return value is null or 0.
  • Each requested Report is cached for 2 minutes, and the Report requested within 2 minutes is the result of the previous analysis. 2 minutes later, the cache expires, we will clear the Report data in the cache, and the new full Report data report is returned when requested again.
  • Test application report retention time is 1 minute.
CategoryNumber of packets to be receivedRequest interval
attention52min
relaxation52min
pressure52min
arousal52min
pleasure52min
sleepcoherence2min
sleep53min

Affective cloud computing service data report

categoryparameterstypevalue rangedescription
attentionattention_avgfloat[0, 100]attention_average
relaxationrelaxation_avgfloat[0, 100]relaxation_average
relaxation_reclist[float][0, 100]*k, (k≥5)Relaxation is recorded at 0.6x second intervals.
pressurepressure_avgfloat[0, 100]average pressure level
pressure_reclist[float][0, 100]*k, (k≥5)Pressure level is recorded in full, with an interval of 0.6x seconds between points
arousalarousal_avgfloat[0, 100]activation_average
arousal_reclist[float][0, 100]*k, (k≥5)The full record of the activation level, with 0.6x seconds between points
coherence_avg float[0, 100]mean of coherence
coherence_reclist[float][0, 100]*k, (k≥5)coherence is recorded in full, with 0.6x seconds between points
sleepsleep_curvelist[float][0, 100]*k, (k≥5)Sleep curve with 0.6x (x≥10; the default conversion is 10 for session settings with x less than 10) a point. The degree of sleep is continuously depicted throughout the nap. The smaller the value means closer to deep sleep; the larger the value means closer to wakefulness
sleep_pointint[0, +∞)The index of the sleep point timeline, used to mark the sleep point. The subscript of the corresponding sleep curve array, indicating which data point the user fell asleep.
sleep_latencyint[0, +∞)Sleep time, in seconds.
awake_durationint[0, +∞)The duration of awakening, in seconds.
light_durationint[0, +∞)Length of light sleep, in seconds
deep_durationint[0, +∞)Deep_duration, in seconds

Report Request structure

{
"services": "affective",
"op": "report",
"kwargs": {
"cloud_services": [
cloud_service1, # Cloud service data type, attention, relaxation, pressure, etc.
cloud_serviceN
]
}
}

Request Example

{
"services": "effective",
"op": "report",
"kwargs": {
"cloud_services": [
"attention"
]
}
}

Report Response structure

{
"code": 0,
"request": {
"services": "affective",
"op": "report"
},
"data": {
cloud_service1: { #bio-data types, attention, relaxation, pressure, etc.
data_type1: data1, # data_type, packet See Sentiment cloud service data report for details
data_typeN: dataN,
},
cloud_serviceN: {
data_type1: data1,
data_typeN: dataN,
}
}
}

Affective Finish

Finish an Affective Cloud service.

caution
  • You need to request finish when the service runs out, if not, we will assume the service is not stopped.
  • The finish of the service will be requested automatically at the end of the session, but it is not recommended to use session close to end the service, you should finish the service first and then close the session.

Finish Request structure

{
"services": "affective",
"op": "finish",
"kwargs": {
"cloud_services": [
cloud_service1, # bio-data type, attention, relaxation, pressure, etc.
cloud_serviceN
]
}
}

Request Example

{
"services": "affective",
"op": "finish",
"kwargs": {
"cloud_services": [
"attention"
]
}
}

Finish Response structure

{
"code": 0,
"request": {
"services": "affective",
"op": "finish"
},
"data": {
"cloud_service": [
cloud_service1, # attention, relaxation, pressure, etc.
cloud_serviceN
]
}
}